package com.airticketbooking.controller.user;

import com.airticketbooking.common.domain.R;
import com.airticketbooking.po.Member;
import com.airticketbooking.service.MemberService;
import com.airticketbooking.vo.MemberVO;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author Mr.J
 * @version 1.0.0
 * @date 2024/11/14
 * @desc
 */
@RequestMapping("air/user/member")
@RestController
@Api(tags = "用户端会员相关接口")
@RequiredArgsConstructor
@Slf4j
public class MemberController {

	private final MemberService memberService;


//	查看会员信息

	@GetMapping()
	private R<MemberVO> getMemberInfo() {

		try {
			MemberVO memberVO = memberService.getMemberInfo();
			return R.ok(memberVO);
		} catch (Exception e) {
			return R.error(e.getMessage());
		}
	}

	//	注册会员,根据总消费金额判断是否有资格升级会员
	@PostMapping()
	private R<String> registerMember() {

		try {

			memberService.registerMember();
			return R.ok("注册成功");

		} catch (Exception e) {
			log.error("注册会员失败", e);
			return R.error(e.getMessage());
		}
	}


}
